package Practice1;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 06 - 04
 * Time: 20:10
 */
public class Test3 {
    public static void main(String[] args) {
        StringBuilder stringBuilder = new StringBuilder("abcd");//String变为StringBuilder，利用StringBuilder的构造方法或append方法
        stringBuilder.append(1);
        stringBuilder.append("abc").append(10.0);//在原对象后面追加字符串
        System.out.println(stringBuilder);
        stringBuilder.setCharAt(0, 'z');//将0下标位置的字符改为z
        System.out.println(stringBuilder);
        stringBuilder.insert(1, "AAAAAAAA");//在1下标位置插入字符串AAAAAAAA
        System.out.println(stringBuilder);
        stringBuilder.reverse();//没有创建新对象，在原对象上翻转字符串
        System.out.println(stringBuilder);
        String str = stringBuilder.toString();
        System.out.println(str);//StringBuilder变为String；调用toString方法
    }
}
